﻿using System;
using UnityEngine;

namespace DL.AI.AIGOAP
{
    public class AgentBelief
    {
        public string Name { get;}

        public Func<bool> m_Condition = () => false;
        public Func<Vector3> m_ObservedLocation = () => Vector3.zero;
        
        public Vector3 Location => m_ObservedLocation.Invoke();
        
        AgentBelief(string name)
        {
            Name = name;
        }

        public bool Evaluate() => m_Condition.Invoke();
        
        
        /// <summary>
        /// 构建器
        /// </summary>
        public class Builder
        {
            private readonly AgentBelief m_Belief;

            public Builder(string name)
            {
                m_Belief = new(name); 
            }

            public Builder WithCondition(Func<bool> condition)
            {
                m_Belief.m_Condition = condition;
                return this;
            }
        
            public Builder WithLocation(Func<Vector3> observedLocation)
            {
                m_Belief.m_ObservedLocation = observedLocation;
                return this;
            }
            
            public AgentBelief Build() => m_Belief;
        }
    }

    
   
    
    
    
    
}